package com.ww.java8.fp.lambda;

/**
 * TODO
 *
 * @author wanggw
 * @date 2022-11-14 23:35:30
 */
public class LambdaExpressions {
    static Body bod = h -> h + " No Parens!";
    static Body bod2 = (h) -> h + " More details";
    static Description desc = () -> "Short info";
    static Multi multi = (h, n) -> h + n;
    static Description moreLines = () -> {
        System.out.println("moreLines()");
        return "from moreLines()";
    };

    /**
     * 输出
     * Oh! No Parens!
     * Hi! More details
     * Short info
     * Pi!3.14159
     * moreLines()
     * from moreLines()
     * @param args
     */
    public static void main(String[] args) {
        System.out.println(bod.detailed("Oh!"));
        System.out.println(bod2.detailed("Hi!"));
        System.out.println(desc.brief());
        System.out.println(multi.twoArg("Pi!", 3.14159));
        System.out.println(moreLines.brief());
    }
}

interface Description {
    String brief();
}

interface Body {
    String detailed(String head);
}

interface Multi {
    String twoArg(String head, Double d);
}